package cn.client.data.remoteData

import cn.client.data.remoteData.bean.AddMindfulnessLogBody
import cn.client.data.remoteData.bean.AvoidancePainBean
import cn.client.data.remoteData.bean.AvoidancePainReq
import cn.client.data.remoteData.bean.BaseResp
import cn.client.data.remoteData.bean.BuildGroupApply
import cn.client.data.remoteData.bean.DraftInfo
import cn.client.data.remoteData.bean.DraftItem
import cn.client.data.remoteData.bean.DynamicData
import cn.client.data.remoteData.bean.EmotionLogBean
import cn.client.data.remoteData.bean.EmotionLogReq
import cn.client.data.remoteData.bean.EvaluateItem
import cn.client.data.remoteData.bean.FriendCardItem
import cn.client.data.remoteData.bean.FriendInfo
import cn.client.data.remoteData.bean.GetEvaluate
import cn.client.data.remoteData.bean.InsertEvaluate
import cn.client.data.remoteData.bean.JoinGroup
import cn.client.data.remoteData.bean.LoginRes
import cn.client.data.remoteData.bean.MindfulnessGroup
import cn.client.data.remoteData.bean.MindfulnessLog
import cn.client.data.remoteData.bean.MindfulnessMedia
import cn.client.data.remoteData.bean.MindfulnessRequestWithUid
import cn.client.data.remoteData.bean.PageSelect
import cn.client.data.remoteData.bean.PageSelectByMid
import cn.client.data.remoteData.bean.PageSelectByUid
import cn.client.data.remoteData.bean.PushSignUpInfo
import cn.client.data.remoteData.bean.ReceiveFriendApply
import cn.client.data.remoteData.bean.SearchFriend
import cn.client.data.remoteData.bean.SearchFriendRes
import cn.client.data.remoteData.bean.SelectUidAndMid
import cn.client.data.remoteData.bean.SendFriendApply
import cn.client.data.remoteData.bean.TakeD
import cn.client.data.remoteData.bean.TakeFriendApply
import cn.client.data.remoteData.bean.UploadNickname
import cn.client.data.remoteData.bean.User
import cn.client.data.remoteData.bean.UserBasicInfo
import cn.client.data.remoteData.bean.UserInfo
import cn.client.data.remoteData.bean.UserInfoCards
import cn.client.data.remoteData.bean.VerifyAccount
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.Field
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.PartMap
import retrofit2.http.Path

/**
 * 基础的网络请求， 使用协程,返回值无需定义返回类型为Call
 */

interface ApiService {
    /**
     * 用户模块
     */
    // 登录-账号验证
    @POST("/login/account")
    suspend fun signInFirst(@Body verifyAccount: VerifyAccount): BaseResp<Any>

    // 登录-密码验证
    @POST("/login/account&password")
    suspend fun signInSecond(@Body user: User): BaseResp<LoginRes>

    // 退出登录
    @GET("/login/logout/{uid}")
    suspend fun signOut(@Path("uid") uid: Int): BaseResp<Any>

    // 注册-验证账号是否可以注册
    @POST("/register/email")
    suspend fun signUpFirst(@Body verifyAccount: VerifyAccount): BaseResp<Any>

    // 注册-校验验证码
    @POST("/register/information")
    suspend fun signUpSecond(@Body user: User): BaseResp<Any>

    // 注册-提交注册信息
    @POST("/register/verify")
    suspend fun signUpThird(@Body push: PushSignUpInfo): BaseResp<Any>

    // 用户信息
    @GET("/user/info/{uid}")
    suspend fun userInfo(@Path("uid") uid: Int): BaseResp<UserInfo>

    // 修改用户基础信息
    @POST("/user/uploadUserInfo")
    suspend fun uploadUserBasicInfo(@Body userBasicInfo: UserBasicInfo): BaseResp<Any>

    // 获取用户卡片
    @GET("/user/userItem/{uid}")
    suspend fun getUserCards(@Path("uid") uid: Int): BaseResp<UserInfoCards>

    // TODO: 修改头像和背景
    @Multipart
    @POST("/user/uploadAvatar")
    suspend fun uploadUserAvatar(
        @Part file: MultipartBody.Part,
        @Part("uid") uid: RequestBody
    ): BaseResp<Any>


    /**
     * 联系人模块
     */

    // 搜索用户
    @POST("/friend/search")
    suspend fun searchFriend(@Body searchFriend: SearchFriend): BaseResp<SearchFriendRes>

    // 发送好友申请
    @POST("/friendApply/send")
    suspend fun sendFriendApply(@Body sendFriendApply: SendFriendApply): BaseResp<Any>

    // 接收好友申请
    @GET("/friendApply/receive/{uid}")
    suspend fun receiveFriendApply(@Path("uid") uid: Int): BaseResp<List<ReceiveFriendApply>>

    // 同意好友申请
    @POST("/friendApply/agree")
    suspend fun agreeFriendApply(@Body agreeFriendApply: TakeFriendApply): BaseResp<Any>

    // 忽略好友申请
    @POST("/friendApply/ignore")
    suspend fun ignoreFriendApply(@Body ignoreFriendApply: TakeFriendApply): BaseResp<Any>

    // 好友列表
    @GET("/friend/friendList/{uid}")
    suspend fun friendList(@Path("uid") uid: Int): BaseResp<List<FriendCardItem>>

    // 好友详情信息
    @GET("/friend/friendInfo/{fid}")
    suspend fun friendInfo(@Path("fid") fid: Int): BaseResp<FriendInfo>

    // 修改好友昵称
    @POST("/friend/modify")
    suspend fun updateNickname(@Body uploadNickname: UploadNickname): BaseResp<Any>


    /**
     * 动态模块
     */

    // 上传动态
    @Multipart
    @POST("/dynamic/publish")
    suspend fun publishDynamic(
        @Part("uid") uid: RequestBody,
        @Part("content") content: RequestBody,
        @Part("category") category: RequestBody,
        @Part images: List<MultipartBody.Part>? = null,
        @Part("subject") subject: RequestBody? = null
    ): BaseResp<Any>

    // 查看具体动态的信息
    @POST("/dynamic/select")
    suspend fun selectDynamic(@Body selectDynamic: TakeD): BaseResp<DynamicData>

    // 获取动态列表
    @POST("/dynamic/selectList")
    suspend fun selectDynamicList(@Body selectDynamicList: PageSelectByUid): BaseResp<List<DynamicData>>

    // TODO: 修改动态


    // 删除动态
    @POST("/dynamic/delete")
    suspend fun deleteDynamic(@Body deleteDynamic: TakeD): BaseResp<Any>

    // 查看草稿列表
    @GET("/draft/list/{uid}")
    suspend fun selectDraftList(@Path("uid") uid: Int): BaseResp<List<DraftItem>>

    // 查看指定草稿
    @GET("/draft/info/{id}")
    suspend fun selectDraftInfo(@Path("id") id: Int): BaseResp<DraftInfo>

    // 删除草稿
    @POST("/draft/delete")
    suspend fun deleteDraft(@Body deleteDraft: TakeD): BaseResp<Any>

    // 草稿转动态
    @POST("/draft/push")
    suspend fun pushDraft(@Body pushDraft: TakeD): BaseResp<Any>

    /**
     * 正念模块
     */
    // 获取正念资源列表
    @POST("/mindfulnessMedia/likeSelectPage")
    suspend fun getMediaList(@Body pageSelect: PageSelect): BaseResp<List<MindfulnessMedia>>

    // 根据用户id获取正念资源列表
    @POST("/mindfulnessMedia/selectByUid")
    suspend fun getMediaListByUid(@Body pageSelect: PageSelectByUid): BaseResp<List<MindfulnessMedia>>

    // 获取正念信息
    @POST("/mindfulnessMedia/selectById")
    suspend fun getMediaInfo(@Body selectUidAndMid: SelectUidAndMid): BaseResp<MindfulnessMedia>

    // 获取正念团体列表
    @POST("/group/selectList")
    suspend fun getGroupList(@Body pageSelect: PageSelect): BaseResp<List<MindfulnessGroup>>

    // 收藏正念
    @POST("/collect/add")
    suspend fun collectMindfulness(@Body midAndUid: MindfulnessRequestWithUid): BaseResp<String>
    // 取消收藏正念
    @POST("/collect/delete")
    suspend fun unCollectMindfulness(@Body unCollect: MindfulnessRequestWithUid): BaseResp<String>
    // 查看收藏
    @GET("/collect/select/{uid}")
    suspend fun selectCollectMindfulness(@Path("uid") uid: Int): BaseResp<List<MindfulnessMedia>>

    // 新增正念评分
    @POST("/evaluate/add")
    suspend fun addEvaluateInMindfulness(@Body insertEvaluate: InsertEvaluate): BaseResp<Any>

    // 修改正念评分
    @POST("/evaluate/update")
    suspend fun updateEvaluateInMindfulness(@Body updateEvaluate: InsertEvaluate): BaseResp<Any>

    // 获取正念评分信息
    @POST("/evaluate/getInfo")
    suspend fun getEvaluateInfo(@Body selectUidAndMid: SelectUidAndMid): BaseResp<GetEvaluate>

    // 查看评分列表
    @POST("/evaluate/select")
    suspend fun getEvaluateInMindfulness(@Body pageSelectByMid: PageSelectByMid): BaseResp<List<EvaluateItem>>


    // 正念打卡
    @POST("/mindfulnessLog/add")
    suspend fun addMindfulnessLog(@Body add : AddMindfulnessLogBody) : BaseResp<String>

    // 查看打卡
    @POST("/mindfulnessLog/selectByUid")
    suspend fun getMindfulnessLogList(@Body pageSelect: PageSelectByUid): BaseResp<List<MindfulnessLog>>

    // 正念团体创建申请
    @POST("/group/apply")
    suspend fun buildGroup(@Body groupApply: BuildGroupApply): BaseResp<String>


    // 查看已加入的团体
    @POST("/group/relationJoin")
    suspend fun getJoinGroupList(@Body pageSelect: PageSelectByUid): BaseResp<List<JoinGroup>>

    /**
     * 健康管理模块
     */

    // 痛苦回避列表-新增
    @POST("/avoidancePain/add")
    suspend fun addAvoidancePain(@Body req: AvoidancePainReq): BaseResp<Any>

    // 痛苦回避列表-查看（列表）
    @POST("/avoidancePain/selectList")
    suspend fun selectListAvoidancePain(@Body req: PageSelectByUid): BaseResp<List<AvoidancePainBean>>

    // 痛苦回避列表-查看（信息）
    @GET("/avoidancePain/select/{id}")
    suspend fun selectInfoAvoidancePain(@Path("id") id: Int): BaseResp<AvoidancePainBean>

    // 痛苦回避列表-删除
    @GET("/avoidancePain/delete/{id}")
    suspend fun deleteAvoidancePain(@Path("id") id: Int): BaseResp<Any>

    // 情绪日志-新增
    @POST("/emotionLog/add")
    suspend fun addEmotionLog(@Body req: EmotionLogReq): BaseResp<Any>

    // 情绪日志-查看（列表）
    @POST("/emotionLog/selectList")
    suspend fun selectListEmotionLog(@Body req: PageSelectByUid): BaseResp<List<EmotionLogBean>>

    // 情绪日志-查看（信息）
    @GET("/emotionLog/select/{id}")
    suspend fun selectInfoEmotionLog(@Path("id") id: Int): BaseResp<EmotionLogBean>

    // 情绪日志-删除
    @GET("/emotionLog/delete/{id}")
    suspend fun deleteEmotionLog(@Path("id") id: Int): BaseResp<Any>

}